<!--<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>代言家庭信息修改页面</title>-->
#@layout()

#define css()
    <!--全局样式-->
    <style type="text/css">
        div{
            background-image: url(http://47.105.208.60:8080/wechat-api/images/loginbg.png);
            background-position: center center;
            background-repeat: no-repeat;
            background-attachment: fixed;
            background-size: cover;
        }
        form#index {
            margin-left:auto;
            margin-right:auto;
            max-width: 500px;
            background: #F7F7F7;
            opacity:0.95;
            padding: 25px 15px 25px 10px;
            font: 12px Georgia, "Times New Roman", Times, serif;
            color: #888;
            text-shadow: 1px 1px 1px #FFF;
            border:1px solid #E4E4E4;
            text-align:center;
        }
        form#index h3 {
            font-size: 25px;
            padding: 0px 0px 10px 40px;
            display: block;
            border-bottom:1px solid #E4E4E4;
            margin: -10px -15px 30px -10px;;
            color: #888;
            text-align:center;
        }
        form#index label {
            display: block;
            margin: 0px;
        }
        form#index label>span {
            float: left;
            width: 20%;
            text-align: right;
            padding-right: 10px;
            margin-top: 10px;
            color: #888;
        }
        form#index input[type="text"], form#index input[type="number"] {
            border: 1px solid #DADADA;
            color: #888;
            height: 30px;
            margin-bottom: 16px;
            margin-right: 6px;
            margin-top: 2px;
            outline: 0 none;
            padding: 3px 3px 3px 5px;
            width: 70%;
            font-size: 12px;
            line-height:15px;
            box-shadow: inset 0px 1px 4px #ECECEC;
            -moz-box-shadow: inset 0px 1px 4px #ECECEC;
            -webkit-box-shadow: inset 0px 1px 4px #ECECEC;
        }
        form#index .button {
            background: #E27575;
            border: none;
            padding: 10px 25px 10px 25px;
            color: #FFF;
            box-shadow: 1px 1px 5px #B6B6B6;
            border-radius: 3px;
            text-shadow: 1px 1px 1px #9E3F3F;
            cursor: pointer;
        }
        form#index label .container{
            width: 300px;
            height: 30px;
            background-color: greenyellow;
            margin-left:auto;margin-right:auto;

        }
        form#index label>span #progress {
            height: 20px;
            background-color: darkgray;
            display: inline-block;
            padding: 3px 0 0 0;
        }

    </style>
#end

#define script()
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>

    <script type="text/javascript" src="https://cdn.bootcss.com/jquery.serializeJSON/2.9.0/jquery.serializejson.js"></script>

    <script>

        window.onload=function(){
            var eid = "#(eid ??)" //getQueryParameter('eid')//获取id
            window.open("#(CPATH)/admin/manage/siteList?num="+eid, "newwindow123", "height=550, width=950, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
        }

        function onLoadByPage(){
            var id = "#(id ??)"; //getQueryParameter('id')//获取id
            //后台查询数据
            var url="http://47.105.208.60:8080/wechat-api/travel/findTravelSiteById";

            //var url="http://localhost:8080/wechat-api/travel/findTravelSiteById";
            var objData = [
                { name: 'id', value: id}
            ];//post方式传送的数据

            $.ajax({
                url: url,
                //JSON.stringify(objData)
                data: objData,
                dataType: 'json',
                type: 'POST',
                success : function(data) {
                    console.log("+++++++++")
                    console.log(data)
                    document.getElementById("id").value=data.id;
                    document.getElementById("eid").value=data.eid;
                    //获取eid查询图片
                    findFile(data.eid);

                    document.getElementById("name").value=data.name;
                    document.getElementById("address").value=data.address;
                    document.getElementById("longitude").value=data.longitude;
                    document.getElementById("latitude").value=data.latitude;

                    console.log(data.etype);
                    $('input:checkbox').each(function (index, domEle) {
                        console.log(domEle)
                        var inputclients = domEle.value;
                        var clients = data.etype.split(",");
                        console.log(inputclients+"111")

                            for (var j = 0; j < clients.length; j++) {
                                if (inputclients == clients[j]) {
                                    console.log(clients[j]+"22222");

                                    domEle.checked = true;
                                }
                            }

                     });
                    document.getElementById("summary").value=data.summary;
                    document.getElementById("video").value=data.video;
                    document.getElementById("report").value=data.report;
                    document.getElementById("username").value=data.username;
                    document.getElementById("userphone").value=data.userphone;

                },error: function(err){
                    console.log("----------")
                    console.log(err)
                }
            });

        }
        onLoadByPage();


        //查询图片
       function findFile(isVal){
            console.log(isVal+"=-=-=-=-=-=-=-")
            $.ajax({
                //url: "http://localhost:8080/wechat-api/file/findFile",
                url: "http://47.105.208.60:8080/wechat-api/file/findFile",

                data: [
                    { name: 'eid', value: isVal}
                ],
                dataType: 'json',
                type: 'POST',
                success : function(data) {
                    console.log("+++++++")
                    console.log(data)

                    var contentArr ='';
                    if (data != '') {
                        for (var index in data){
                            var id =  data[index].id;
                            var eid =  data[index].eid;
                            var picture =  data[index].picture;
                            var shouming =  data[index].shouming;
                            console.log(id+","+eid)
                            var content ="<label id='tr-"+index+"' class='tr'>"+
                                    " <input type='text'  value='"+id+"' style='display: none'/> "+
                                    " <input type='text'  value='"+eid+"' style='display: none'/><br>"+
                                    "<img src='"+picture+"' style='width: 300px;height: 200px'/>"+
                                    " <input type='text' value='"+shouming+"'/>"+
                                    "<input type='button' value='删除' onclick='shanchu("+id+")'/>"+
                                "<input type='button' value='排序' onclick='paixu("+id+")'/>"+
                                    "</label>";
                            contentArr += content
                        }
                        document.getElementById("label").innerHTML = contentArr;
                    }

                },error: function(err){
                    console.log("----------")
                    console.log(err)
                }
            });

        }

        //点击放大缩小图片

        /*  $(function () {
            $('#img').dblclick(function () {
                $(this).toggleClass('min');
                $(this).toggleClass('max');
            });
        });*/
        
        //删除图片
        function shanchu(id) {
            $.ajax({
                url: "http://47.105.208.60:8080/wechat-api/file/updateFile",
                //url: "http://localhost:8080/wechat-api/file/updateFile",
                data: [
                    { name: 'id', value: id}
                ],
                dataType: 'json',
                type: 'POST',
                success : function(data) {
                    console.log("+++++++")
                    console.log(data)

                    window.location.reload();

                },error: function(err){
                    console.log("----------")
                    console.log(err)
                }
            });

        }

        //修改图片排序
        function paixu(id) {
            $.ajax({
                url: "http://47.105.208.60:8080/wechat-api/file/updateFlag",
                //url: "http://localhost:8080/wechat-api/file/updateFlag",
                data: [
                    { name: 'id', value: id}
                ],
                dataType: 'json',
                type: 'POST',
                success : function(data) {
                    console.log("+++++++")
                    console.log(data)

                    window.location.reload();

                },error: function(err){
                    console.log("----------")
                    console.log(err)
                }
            });

        }


        //图文上传
        function shangchuan() {
            window.open("/admin/manage/fileList", "window", "height=300, width=600, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
        }

        //代言家庭保存修改的信息

        function baocun() {
            var obj = document.getElementsByName("etype");

            var val = [];

           for(var k=0;k<obj.length;k++){
               if(obj[k].checked){
                   val.push(obj[k].value)

               }
           }
            console.log(val)

            var eee = val.join(',');

            var array ={
                id:document.getElementById("id").value,
                eid:document.getElementById("eid").value,
                name:document.getElementById("name").value,
                address:document.getElementById("address").value,
                longitude:document.getElementById("longitude").value,
                latitude:document.getElementById("latitude").value,
                summary:document.getElementById("summary").value,
                etype:eee,
                video:document.getElementById("video").value,
                report:document.getElementById("report").value,
                username:document.getElementById("username").value,
                userphone:document.getElementById("userphone").value
            };
                console.log(array);
            $.ajax({
                url: "http://47.105.208.60:8080/wechat-api/travel/savesite",
                //url:"http://localhost:8080/wechat-api/travel/savesite",
                data:
                    JSON.stringify(array),

                    //JSON.stringify($('#index').serializeJSON()),

                    type: 'POST',
                    dataType: "json",
                contentType:"application/json",
                success : function(data) {
                    console.log("+++++++++")
                    console.log(data)
                    alert("提交成功")
                    document.getElementById("index").reset();

                    window.location.href="#(CPATH)/admin/manage/site2";

                },error: function(err){
                    console.log("----------")
                    console.log(err)
                    alert("提交失败")
                }
            });

        }

    </script>
#end
<!--</head>
<body>-->

#define content()
<div>
<form id="index" onsubmit="return false" action="##" method="post" >
    <h3 style="align-content: center">民宿信息添加</h3>

    <label>
        <input type="text" name="id" class="id" id="id" style="display: none">
    </label>
    <label>
        <span>农户编号: </span>
        <input type="text" name="eid" class="eid" id="eid">
    </label>
    <label>
        <span>农户名称:</span>
        <input type="text" name="name" class="name" id="name">
    </label>
    <label>
        <span>农户所属乡镇:</span>
        <input type="text" name="address" class="address" id="address">
    </label>
    <label>
        <span>经度:</span>
        <input type="text" name="longitude" class="longitude" id="longitude">
    </label>
    <label>
        <span>纬度:</span>
        <input type="text" name="latitude" class="latitude" id="latitude">
    </label>
    <!--<label>
        <span>类型:</span>

            <input type="checkbox" name="etype" value="佛系人家" id="etype1">佛系人家
            <input type="checkbox" name="etype" value="健身人家" id="etype2">健身人家
            <input type="checkbox" name="etype" value="农林人家" id="etype3">农林人家<br>
            <input type="checkbox" name="etype" value="文艺人家" id="etype4">文艺人家
            <input type="checkbox" name="etype" value="手艺人家" id="etype5">手艺人家
            <input type="checkbox" name="etype" value="土味人家" id="etype6">土味人家<br>

    </label>--><br>
    <label>
        <span>简介:</span>
        <input type="text" name="summary" class="summary" id="summary">
    </label>



        <label id="label" class="label">
            <span>图片展示:</span>

       </label>

    
    <label>
        <span>图文上传:</span>
        <input type="button" value="点击上传" onclick="shangchuan()"><br><br>
        &nbsp;&nbsp;&nbsp;
    </label>

    <label>
        <span>腾讯视频地址:</span>
        <input type="text" name="video" class="video" id="video" >

    </label><br>
   <!-- <label>
        <input type="text" name="thumbnail" class="thumbnail" id="thumbnail" style="display: none">
    </label>-->
    <label>
        <span>上报人:</span>
        <input type="text" name="report" class="report" id="report">
    </label>
    <label>
        <span>联系人: </span>
        <input type="text" name="username" class="username" id="username">
    </label>
    <label>
        <span>联系电话:</span>
        <input type="number" name="userphone" class="userphone" id="userphone">
    </label>


    <input  type="button" class="button" value="保存" onclick="baocun()">

</form>
</div>
#end
<!--
</body>
</html>-->
